
package com.tistory.common.vo;

import com.tistory.commons.utils.CommonUtil;


/**
 * <pre>
 *  Value Object.
 * </pre>
 * 
 * Created on : 2015-01-15 Created by : 김형식
 */

public class CommonReq  {

	private static final long serialVersionUID = 1L;
	private String searchStRegDt;
	private String searchEdRegDt;
	private String searchValueType;
	private String searchValueType_1;
	private String searchValueType_2;
	private String searchValue;
	private String user_id;

	
	private long page = 1;
	// 전체 컨텐츠 갯수
	private long totalCount;
	// 한 페이지 당 컨텐츠 갯수
	private int scale = 10;
	// 총 페이지 갯수
	private long totalPage;
	private long startRow = 1;
	private long endRow = 10;
	
	public long getPage() {
		return page;
	}
	public void setPage(long page) {
		this.page = page;
		scale = scale == 0 ? 10 : scale;
		startRow = (page - 1) * scale + 1;
		endRow = page * scale;
	}
	public void setPage(long page, int scale) {
		setPage(page);
		setScale(scale);
	}
	public long getTotalCount() {
		return totalCount;
	}
	public void setTotalCount(long totalCount) {
	    this.totalCount = totalCount;
		if (scale > 0) {
			totalPage = (totalCount + scale - 1) / scale;
			totalPage = totalPage == 0 ? 1 : totalPage;
		}
	}
	public int getScale() {
		return scale;
	}
	public void setScale(int scale) {
		this.scale = scale;
		page = page == 0 ? 1 : page;
		startRow = (page - 1) * scale + 1;
		endRow = page * scale;
	}
	public long getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(long totalPage) {
		this.totalPage = totalPage;
		if (totalPage == 0 && scale > 0) {
			totalPage = (totalCount + scale - 1) / scale;
			totalPage = totalPage == 0 ? 1 : totalPage;
		}
	}
	public long getStartRow() {
		return startRow;
	}
	public void setStartRow(long startRow) {
		this.startRow = startRow;
	}
	public long getEndRow() {
		return endRow;
	}
	public void setEndRow(long endRow) {
		this.endRow = endRow;
	}
	
	public String getSearchValue() {
		return searchValue;
	}
	public void setSearchValue(String searchValue) {
		//searchValue = CommonUtil.removeSpecial(searchValue);
		this.searchValue = searchValue;
	}
	/**
	 * @return the searchStRegDt
	 */
	public String getSearchStRegDt() {
		return searchStRegDt;
	}
	/**
	 * @param searchStRegDt the searchStRegDt to set
	 */
	public void setSearchStRegDt(String searchStRegDt) {
		searchStRegDt = CommonUtil.removeSpecial(searchStRegDt);
		searchStRegDt = searchStRegDt.replaceAll("/", "");
		searchStRegDt = searchStRegDt.replaceAll("-", "");
		
		this.searchStRegDt = searchStRegDt;
	}
	/**
	 * @return the searchEdRegDt
	 */
	public String getSearchEdRegDt() {
		return searchEdRegDt;
	}
	/**
	 * @param searchEdRegDt the searchEdRegDt to set
	 */
	public void setSearchEdRegDt(String searchEdRegDt) {
		searchEdRegDt = CommonUtil.removeSpecial(searchEdRegDt);
		searchEdRegDt = searchEdRegDt.replaceAll("/", "");
		searchEdRegDt = searchEdRegDt.replaceAll("-", "");
		
		this.searchEdRegDt = searchEdRegDt;
	}
	/**
	 * @return the searchValueType
	 */
	public String getSearchValueType() {
		return searchValueType;
	}
	/**
	 * @param searchValueType the searchValueType to set
	 */
	public void setSearchValueType(String searchValueType) {
		this.searchValueType = searchValueType;
	}
	/**
	 * @return the searchValueType_1
	 */
	public String getSearchValueType_1() {
		return searchValueType_1;
	}
	/**
	 * @param searchValueType_1 the searchValueType_1 to set
	 */
	public void setSearchValueType_1(String searchValueType_1) {
		this.searchValueType_1 = searchValueType_1;
	}
	/**
	 * @return the searchValueType_2
	 */
	public String getSearchValueType_2() {
		return searchValueType_2;
	}
	/**
	 * @param searchValueType_2 the searchValueType_2 to set
	 */
	public void setSearchValueType_2(String searchValueType_2) {
		this.searchValueType_2 = searchValueType_2;
	}
	/**
	 * @return the user_id
	 */
	public String getUser_id() {
		return user_id;
	}
	/**
	 * @param user_id the user_id to set
	 */
	public void setUser_id(String user_id) {
		this.user_id = user_id;
	}
	
	
}
